package action.country;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.dao.CountryModel;
import controller.Action;
import controller.ActionForward;

public class ActionDeleteCountry implements Action {

	@Override
	public ActionForward execute(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		CountryModel dao=new CountryModel();
		int page=1;
		int limit=10;
		String search="";
		if(request.getParameter("page")!=null){
			page=Integer.parseInt(request.getParameter("page"));
		}
		if(request.getParameter("search")!=null){
			search=request.getParameter("search");
		}
		if(request.getParameter("limit")!=null){
			limit=Integer.parseInt(request.getParameter("limit"));
		}
		int country_id=Integer.parseInt(request.getParameter("id"));
		if(dao.delete(country_id)){
			System.out.println("Deleted successfully.");
		}else{
			System.out.println("Deleting fail!!!");
		}
		
		ActionForward forward=new ActionForward();
		forward.setPath("list-country-process.sp?page="+page);
		forward.setRedirect(true);
		return forward;
	}

}
